﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Organizer
{
    public class Statistic
    {
        public const int id = 1;

        public int allTasks;
        public int doneTasks;
        public int processesTasks;
        public TimeSpan evaluateTime;
        public TimeSpan spendTime;
        public TimeSpan errorEvaluate;
        public TimeSpan errorEvaluateByTask;

        public Statistic()
        {
            allTasks = 0;
            doneTasks = 0;
            processesTasks = 0;
            evaluateTime = TimeSpan.Zero;
            spendTime = TimeSpan.Zero;
            errorEvaluate = TimeSpan.Zero;
            errorEvaluateByTask = TimeSpan.Zero;
        }

        public Statistic(int all, int done, int proces, TimeSpan eval, TimeSpan spend, TimeSpan error, TimeSpan errorByTask)
        {
            allTasks = all;
            doneTasks = done;
            processesTasks = proces;
            evaluateTime = eval;
            spendTime = spend;
            errorEvaluate = error;
            errorEvaluateByTask = errorByTask;
        }


        public void Add(Task task)
        {
            allTasks++;
            processesTasks++;
            evaluateTime += new TimeSpan(task.hours, task.mins, 0);
        }

        public void Pause(Task task)
        {
            spendTime += new TimeSpan(task.spendHour, task.spendMin, task.spendSec);
        }

        public void Complete(Task task)
        {

            doneTasks++;
            processesTasks--;
            errorEvaluate = spendTime - evaluateTime;
            int temp = (errorEvaluate.Days * 24 * 60 + errorEvaluate.Hours * 60*60 + errorEvaluate.Minutes*60+errorEvaluate.Seconds) / doneTasks;
            errorEvaluateByTask = new TimeSpan(temp / 3600, temp/60, temp%60);
        }



    }
}
